package com.genexususa.eo.bing.data.wsSubclasses;

import com.genexususa.eo.bing.CampaignManagementServiceClasses.KeywordDestinationUrl;
import com.genexususa.eo.bing.data.GxItemException;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class GxKeywordDestinationUrl extends KeywordDestinationUrl {
    private long gxKeywordId;

    public GxKeywordDestinationUrl(Element element) throws IllegalArgumentException, GxItemException {
        if (element.getElementsByTagName("DestinationUrl").getLength() > 0 &&
            element.getElementsByTagName("DestinationUrl").item(0).getChildNodes().getLength() > 0) {
            this.setDestinationUrl(((Node) element.getElementsByTagName("DestinationUrl").item(0).getChildNodes().item(0)).getNodeValue());
        }
        if (element.getElementsByTagName("GxKeywordId").getLength() > 0 &&
            element.getElementsByTagName("GxKeywordId").item(0).getChildNodes().getLength() > 0 &&
            Long.valueOf(((Node)element.getElementsByTagName("GxKeywordId").item(0).getChildNodes().item(0)).getNodeValue()) != 0) {
            this.gxKeywordId = Long.valueOf(((Node)element.getElementsByTagName("GxKeywordId").item(0).getChildNodes().item(0)).getNodeValue());
        } else {
            throw new GxItemException("Missing external Keyword id");
        }
        if (element.getElementsByTagName("BingKeywordId").getLength() > 0 &&
            element.getElementsByTagName("BingKeywordId").item(0).getChildNodes().getLength() > 0 &&
            Long.valueOf(((Node)element.getElementsByTagName("BingKeywordId").item(0).getChildNodes().item(0)).getNodeValue()) != 0) {
            this.setKeywordId(Long.valueOf(((Node) element.getElementsByTagName("BingKeywordId").item(0).getChildNodes().item(0)).getNodeValue()));
        }
    }

    public long getGxKeywordId() {
        return gxKeywordId;
    }

    public void setGxKeywordId(long gxKeywordId) {
        this.gxKeywordId = gxKeywordId;
    }
}
